<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>传智商城后台</title>
	<link href="./css/admin.css" rel="stylesheet" />
	<script src="./js/jquery.min.js"></script>
</head>
<body>
<div id="top">
	<h1 class="left">传智商城 后台管理系统</h1>
	<ul class="right">
		<li>欢迎您：admin</li>
		<li>|</li><li><a href="#" target="_blank">前台首页</a></li>
		<li>|</li><li><a href="#">退出登录</a></li>
	</ul>
</div>
<div id="main">
	<div id="menu" class="left">
		<ul><li><a href="#" id="Index_index">后台首页</a></li>
			<li><a href="#" id="Goods_add">商品添加</a></li>
			<li><a href="#" id="Goods_index">商品列表</a></li>
			<li><a href="#" id="Attribute_index">商品属性</a></li>
			<li><a href="#" id="Category_index">商品分类</a></li>
			<li><a href="#" id="Recycle_index">回收站</a></li>
			<li><a href="#" id="Member_index">会员管理</a></li>
		</ul>
	</div>
	<div id="content">
		<div class="item"><div class="title">商品分类列表</div>
<div class="title-btn left"><a href="#">添加分类</a></div>
<div class="data-tree clear">
		<div>图书 <a href="#" onclick="del(this,16)">删除</a>
					<div>教育 <a href="#" onclick="del(this,21)">删除</a>
					<div>教材 <a href="#" onclick="del(this,23)">删除</a>
									</div><div>考试 <a href="#" onclick="del(this,24)">删除</a>
									</div><div>参考书 <a href="#" onclick="del(this,38)">删除</a>
									</div>				</div><div>科技 <a href="#" onclick="del(this,22)">删除</a>
					<div>IT <a href="#" onclick="del(this,25)">删除</a>
									</div><div>医学 <a href="#" onclick="del(this,26)">删除</a>
									</div>				</div><div>少儿 <a href="#" onclick="del(this,34)">删除</a>
					<div>儿童文学 <a href="#" onclick="del(this,39)">删除</a>
									</div><div>少儿英语 <a href="#" onclick="del(this,40)">删除</a>
									</div>				</div><div>管理 <a href="#" onclick="del(this,35)">删除</a>
					<div>经济 <a href="#" onclick="del(this,41)">删除</a>
									</div><div>金融 <a href="#" onclick="del(this,42)">删除</a>
									</div><div>投资 <a href="#" onclick="del(this,43)">删除</a>
									</div>				</div><div>生活 <a href="#" onclick="del(this,36)">删除</a>
					<div>旅游 <a href="#" onclick="del(this,44)">删除</a>
									</div><div>运动 <a href="#" onclick="del(this,45)">删除</a>
									</div>				</div><div>艺术 <a href="#" onclick="del(this,37)">删除</a>
					<div>摄影 <a href="#" onclick="del(this,46)">删除</a>
									</div><div>设计 <a href="#" onclick="del(this,47)">删除</a>
									</div><div>绘画 <a href="#" onclick="del(this,48)">删除</a>
									</div>				</div>				</div><div>家具 <a href="#" onclick="del(this,18)">删除</a>
									</div><div>手机 <a href="#" onclick="del(this,27)">删除</a>
									</div><div>服装 <a href="#" onclick="del(this,28)">删除</a>
									</div><div>家用电器 <a href="#" onclick="del(this,29)">删除</a>
									</div><div>电脑、办公 <a href="#" onclick="del(this,30)">删除</a>
									</div><div>运动户外 <a href="#" onclick="del(this,31)">删除</a>
									</div><div>家具、厨具 <a href="#" onclick="del(this,32)">删除</a>
									</div><div>虚拟物品 <a href="#" onclick="del(this,33)">删除</a>
									</div>	</div>
<script>
	$(".data-tree").on("click","#new_div :button",function(){
		var cname = $("#new_cname").val();
		var pid = $("#new_pid").val();
		var div = $(this);
		$.post("#",{cname: cname, pid: pid},function(msg){
			if (msg === false) {alert('添加失败');return false;}
			var html = "<div>" + cname;
			html += ' <a href="#" onclick="add_line(this,'+msg+')">添加</a> ';
			html += '<a href="#'+msg+'")">修改</a> ';
			html += '<a href="#" onclick="del(this,'+msg+')">删除</a></div>';
			div.parent().parent().append(html);
			div.parent().remove();
        },'json');
	});
	function add_line(obj, id){
		var html = '<div id="new_div">子分类：<input type="text" id="new_cname" />';
		html += '<input type="button" value="提交" />';
		html += '<input type="hidden" value="'+id+'" id="new_pid" /></div>';
		if($("#new_div").val()===undefined){
			$(obj).parent().append(html);
			$("#new_cname").focus();
		}else{
			$("#new_div").remove();
		}
	}
	function del(obj, id) {
		$.get("__CONTROLLER__/remove", {cid: id}, function (msg) {
			if (msg.flag === true) {
				$(obj).parent().remove();
			}else{
				alert(msg.msg);
			}
		}, "json");
	}
</script></div>
	</div>
</div>
<script>
	$("#Category_index").addClass("curr");
</script>
</body>
</html>